/**
 * Description
 *
 * Creation Date 21/12/2017
 * @author Candy
 */
import Immutable from 'immutable'
import * as types from './../actionTypes';

const initialState = Immutable.fromJS(
	{
		isFetching: false,
		productList: {},
		productData: {},
	}
)

const cartReducers = (state = {}, action={}) => {
	//记录商品列表页数据状态
	switch(action.type){
		case types.INIT_CART:
			return Object.assign({},state,action);
		case types.REMOVE_CART:
			return Object.assign({},state,action);
		case types.ADD_CART:
			return Object.assign({},state,action);
		case types.REDUCE_CART:
			return Object.assign({},state,action);
		case types.PAY_MENT:
			return Object.assign({},state,action);
		default:
			return state
	}
};

const profileReducers = (state={login: false}, action={}) => {
	switch(action.type){
		case types.LOGIN:
			return Object.assign({},state,action);
		case types.SAVE_ADDRESS:
			return Object.assign({},state,action);
		default:
			return state
	}
};

export default {
	cartReducers,
	profileReducers
}